package ui;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.Vector;


public class AgentManagerMIDlet extends MIDlet{
	private Display display;
	
		public AgentManagerMIDlet(){
			display = Display.getDisplay(this);
			System.out.println("In Constructor()");
		}
		
		/*Called upon instanciation */
		public void startApp()
	    {
	        Displayable current = Display.getDisplay(this).getCurrent();
	        if(current == null)
	        {
	            ui.AgentCreationScreen creationScreen = 
	            	new ui.AgentCreationScreen(this, "Please Selece an Agent to create",display);
	            display.setCurrent(creationScreen);
	        }
	    }
		
		public Object[] vecToArray(Vector v){
			Object[] array = new Object[v.size()];
			for(int i = 0 ; i < array.length ; i++){
				array[i] = v.elementAt(i);
			}
			return array;
		}
		
		
		public void createMeetingAgent(Vector dests, Vector startTimes,Vector endTimes,int meetingLength ){
			int numDestinations = dests.size();
			int numTimes = startTimes.size();
			boolean[][] rTimes = new boolean[numDestinations][numTimes];
			String[] destinations = (String[])vecToArray(dests);
			String[] meetingStartTimes = (String[])vecToArray(startTimes);
			String[] meetingEndTimes = (String[])vecToArray(endTimes);
			
			agent.MeetingAgent agent = new agent.MeetingAgent( meetingStartTimes,
													meetingEndTimes,
													dests.size(),
													destinations,
													0,
													rTimes);
			
		}

		/* On pause */
	    public void pauseApp()
	    {
	    }

	    /*On destruction */
	    public void destroyApp(boolean b)
	    {
	    }


	    // A convenience method for exiting
	    void exitRequested()
	    {
	        destroyApp(false);
	        notifyDestroyed();
	    }
}
